package com.testfileupload.uploadimg.design.iterator;

import java.util.ArrayList;

public class ProjectIterator implements IProjectIterator {
    //所有项目都放在arraylist中
    private ArrayList<IProject> projects = new ArrayList<>();
    private int currentItem = 0;
    //传入构造函数projects

    public ProjectIterator(ArrayList<IProject> projects) {
        this.projects = projects;
    }

    //判断是否还有元素
    @Override
    public boolean hasNext() {
        //定义一个返回值
        boolean b = true;
        if (this.currentItem >= projects.size() || this.projects.get(this.currentItem) == null) {
            b = false;
        }
        return b;
    }
    //获取下一个值
    @Override
    public Object next() {
        return this.projects.get(this.currentItem++);
    }

}
